package com.iflytek.uoamp.agent.monitor.mcagent;

import java.util.HashMap;
import java.util.Map;

import com.iflytek.uoamp.agent.core.sender.monitorsender.monitorinterface.IItem;
import com.iflytek.uoamp.agent.core.sender.monitorsender.responseObj.AgentLog;

public class MCAgentLog implements IItem {

	private AgentLog log;
	
	public MCAgentLog(){
		
	}
	
	public MCAgentLog(AgentLog log) {
		this.log = log;
	}

	public MCAgentLog(byte[] log) {
		String temp = new String(log);
		String[] values = temp.split((char)31+"");
		AgentLog agentlog = new AgentLog();
		Map<String ,String> headers = new HashMap<String, String>();
		for(int i=1;i<values.length;i++){
			String[] kvs = values[i].split("~");
			
			headers.put(kvs[0], kvs[1]);
		}
		headers.put("version", MCAgentConfig.getInstance().getVersion());
		agentlog.setHeaders(headers);
		this.log = agentlog;
	}

	public AgentLog getLog() {
		return log;
	}

	public void setLog(AgentLog log) {
		this.log = log;
	}

	@Override
	public String caseToString() {
		return "";
		//		return MCAgentConfig.getInstance().getMonitoredPointIp();
	}

	@Override
	public String getSendPath() {
		return "agentlog";
	}

	@Override
	public String getSendListPath() {
		return "";
	}

}
